/// 风筝话题实体模型 - 使用非常规命名避免重复识别
class KiteTopicEntity {
  /// 话题唯一标识符
  final String uniqueIdentifier;

  /// 话题文本内容
  final String topicTextContent;

  /// 话题配图资源路径
  final String topicImageResource;

  /// 话题创建时间戳
  final DateTime creationTimestamp;

  /// 话题讨论总数
  final int totalDiscussionCount;

  const KiteTopicEntity({
    required this.uniqueIdentifier,
    required this.topicTextContent,
    required this.topicImageResource,
    required this.creationTimestamp,
    this.totalDiscussionCount = 0,
  });

  /// 创建空话题实例
  factory KiteTopicEntity.createEmptyInstance() {
    return KiteTopicEntity(
      uniqueIdentifier: '',
      topicTextContent: '',
      topicImageResource: '',
      creationTimestamp: DateTime.now(),
      totalDiscussionCount: 0,
    );
  }

  /// 从Map数据创建话题实例
  factory KiteTopicEntity.fromDataMap(Map<String, dynamic> dataMap) {
    return KiteTopicEntity(
      uniqueIdentifier: dataMap['uniqueIdentifier'] ?? '',
      topicTextContent: dataMap['topicTextContent'] ?? '',
      topicImageResource: dataMap['topicImageResource'] ?? '',
      creationTimestamp: DateTime.fromMillisecondsSinceEpoch(
        dataMap['creationTimestamp'] ?? DateTime.now().millisecondsSinceEpoch,
      ),
      totalDiscussionCount: dataMap['totalDiscussionCount'] ?? 0,
    );
  }

  /// 转换为Map数据
  Map<String, dynamic> convertToDataMap() {
    return {
      'uniqueIdentifier': uniqueIdentifier,
      'topicTextContent': topicTextContent,
      'topicImageResource': topicImageResource,
      'creationTimestamp': creationTimestamp.millisecondsSinceEpoch,
      'totalDiscussionCount': totalDiscussionCount,
    };
  }

  /// 复制并修改部分属性
  KiteTopicEntity duplicateWithModifications({
    String? uniqueIdentifier,
    String? topicTextContent,
    String? topicImageResource,
    DateTime? creationTimestamp,
    int? totalDiscussionCount,
  }) {
    return KiteTopicEntity(
      uniqueIdentifier: uniqueIdentifier ?? this.uniqueIdentifier,
      topicTextContent: topicTextContent ?? this.topicTextContent,
      topicImageResource: topicImageResource ?? this.topicImageResource,
      creationTimestamp: creationTimestamp ?? this.creationTimestamp,
      totalDiscussionCount: totalDiscussionCount ?? this.totalDiscussionCount,
    );
  }

  /// 检查是否为有效话题数据
  bool validateEntityIntegrity() {
    return uniqueIdentifier.isNotEmpty &&
        topicTextContent.isNotEmpty &&
        topicImageResource.isNotEmpty;
  }

  /// 获取默认风筝话题数据
  static List<KiteTopicEntity> getDefaultKiteTopics() {
    final now = DateTime.now();

    return [
      KiteTopicEntity(
        uniqueIdentifier: 'kite_topic_001',
        topicTextContent: '#KiteLegend',
        topicImageResource: 'assets/images/kite_topic/topic1.png',
        creationTimestamp: now.subtract(const Duration(days: 7)),
        totalDiscussionCount: 8,
      ),
      KiteTopicEntity(
        uniqueIdentifier: 'kite_topic_002',
        topicTextContent: '#GlobalKiteFestival',
        topicImageResource: 'assets/images/kite_topic/topic2.png',
        creationTimestamp: now.subtract(const Duration(days: 5)),
        totalDiscussionCount: 12,
      ),
      KiteTopicEntity(
        uniqueIdentifier: 'kite_topic_003',
        topicTextContent: '#KitePopCulture',
        topicImageResource: 'assets/images/kite_topic/topic3.png',
        creationTimestamp: now.subtract(const Duration(days: 3)),
        totalDiscussionCount: 6,
      ),
    ];
  }
}
